<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  
  <title>Jailer - API</title>
  <meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
  <meta name="keywords" content="Data Export Tool" />
  <meta name="description" content="data export referential integrity java jdbc dbms" />
  <link rel="stylesheet" type="text/css" href="styles.css" />
  <link rel="shortcut icon" href="favicon.ico" />
</head>

<body left-margin="0" top-margin="0">
  <div align="left">
    <table style="text-align: left; position: absolute; left: 0pt; top: 0pt;" border="0"
    cellpadding="0" cellspacing="0" height="407" width="100%">
      <tbody>
        <tr>
          <td colspan="2" class="bannerbackground" height="33" width="100%">
            <table border="0" cellpadding="4" cellspacing="0" width="100%">
              <tbody>
                <tr>
                  <td><a href="https://github.com/Wisser/Jailer"><img src="logo.png" hspace="10" /></td> <td class="slogan" width="100%"></a>

                   

                  <td style="text-align: right; width: 100%;"><table border="0" cellpadding="0" cellspacing="0">
                      <tbody>
                        <tr>
                           <td><a href="https://github.com/Wisser/Jailer"><img src="GitHub-Mark-64px.png" title="GitHub" /></a> </td></tr><tr style="height: 100%;"><td>&nbsp;</td>
                        </tr>
                      </tbody>
                    </table> </td>
                </tr>
              </tbody>
            </table>
                <tr>
                  <td colspan="2" class="nav1background"  width="100%">&nbsp;
                  <b><font color="#FFFFFF"><a href="home.htm" target="_self" class=
                  "tlink">&nbsp;Home&nbsp;</a> <a href="quicktour.htm" target=
                  "_self" class="tlink">&nbsp;Quick Tour&nbsp;</a> <a href=
                  "exporting-data.htm" target="_self" class="tlink">&nbsp;Tutorial&nbsp;</a> 
                  <a href="data-browsing.html" target="_self" class=
                  "tlink">&nbsp;Data Browser&nbsp;</a> <a class="tlink" href="videos.html" target="_self">&nbsp;Videos&nbsp;</a> <a href="faq.html" target=
                  "_self" class="tlink">&nbsp;FAQ&nbsp;</a> <a href="api.html"
                  target="_self" class="tlinkA">&nbsp;API&nbsp;</a> <a href=
                  "design.htm" target="_self" class="tlink">&nbsp;Documentation&nbsp;</a> 
                  <a href=
                  "http://sourceforge.net/forum/?group_id=197260" target="_self" class=
                  "tlink">&nbsp;Forum&nbsp;</a> <a href=
                  "http://sourceforge.net/project/showfiles.php?group_id=197260" target=
                  "_self" class="tlink">&nbsp;Download&nbsp;</a>  &nbsp;&nbsp;&nbsp;
                  &nbsp;&nbsp;&nbsp;</font></b></td>
                </tr>

                <tr>
                  <td colspan="2" class="spacer" width="100%"></td> </tr><tr><td class="lmenucontainer">&nbsp;</td>
                </tr>

                <tr>
                  <td class="lmenucontainer" height="100%" valign="top" width="14%">
                    <div align="center">
                      <center>
                        <table border="0" cellpadding="0" cellspacing="0" width="100%">
                          <tbody>
                            <tr>
                              <td height="6px" width="100%"> </td>
                            </tr>
                          </tbody>
                        </table>
                      </center>
                    </div>

                    <ul>
                      <li><a href="api.html" target="_self" class="llinkA">API</a> </li>
                    </ul>

                    <table border="0" cellpadding="5" cellspacing="0" width="100%">
                      <tbody>
                        <tr>
                          <td class="content2background"><img style=
                          "width: 160px; height: 1px;" alt="" src=
                          "architecture-Dateien/vgradp.gif" /></td>
                        </tr>
                      </tbody>
                    </table>

                    <p>&nbsp;</p>
                  </td>

                  <td class="contentbackground" height="418" valign="top" width="86%">
                    <div align="right">
                      <table border="0" cellpadding="0" cellspacing="0" height="542"
                      width="98%">
                        <tbody>
                          <tr>
                            <td class="contentbackground" height="21" width="100%">
                            <br /></td>
                          </tr>

                          <tr>
                            <td class="content" height="520" valign="top" width="100%">
                              
                              <big><span style="font-weight: bold;">Application
                              Programming Interface<br />
                              <br /></span></big> The API provides programmatic access to
                              the data export and import functionality.<br />
                              <br />
                              <br />
                              <big><span style=
                              "font-weight: bold;">Dependencies</span></big>

                              <ul>
                                <li>jailer-engine-<i>version</i>.jar&nbsp;(<a href="https://mvnrepository.com/artifact/io.github.wisser/jailer-engine">MVN-Repository</a>, also included in jailer-<i>version</i>.zip)</li>

                                <ul><li>If you are not using a dependency management system, add the required jar-files in the <i>lib/</i> directory to the class path manually.</li>
                              <li>The version number of the jailer-engine corresponds to the jailer version number where the major and minor numbers are identical. <br>For example, <i>jailer-engine-16.5.jar</i> is compatible with <i>Jailer 16.5.8.</i><br />
                               </li></ul></ul>
                              <big><span style="font-weight: bold;">Classes</span></big>

                              <ul>
                                <li><a href="api/net/sf/jailer/api/Subsetter.html"
                                target="_blank">net.sf.jailer.api.Subsetter</a> <br />
                                generates a subset of a relational database that respects
                                foreign key constraints.</li>

                                <li><a href="api/net/sf/jailer/api/Importer.html" target=
                                "_blank">net.sf.jailer.api.Importer</a> <br />
                                imports subset data.<br /></li>
                              </ul><br />
                              <big><span style=
                              "font-weight: bold;">Example</span></big><br />
                              <br />
                              The example is included in the sources. It extracts some data
                              from the "demo-scott" database and imports it into another
                              database "demo-scott-subset".<br />

                              <ul>
                                
                                <li>Source<br />
<pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> APIExample <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// JDBC connection pool size</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> POOL_SIZE <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Folder containing models and databases</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">File</span> baseFolder <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// The subsetter</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> Subsetter subsetter <span style="color: #339933;">=</span> 
		<span style="color: #000000; font-weight: bold;">new</span> Subsetter<span style="color: #009900;">&#40;</span>
			<span style="color: #000000; font-weight: bold;">new</span> BasicDataSource<span style="color: #009900;">&#40;</span>
					<span style="color: #0000ff;">&quot;org.h2.Driver&quot;</span>, <span style="color: #0000ff;">&quot;jdbc:h2:&quot;</span> <span style="color: #339933;">+</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span>baseFolder, <span style="color: #0000ff;">&quot;demo-db/demo-scott&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getAbsolutePath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #0000ff;">&quot;sa&quot;</span>, <span style="color: #0000ff;">&quot;&quot;</span>,
					POOL_SIZE,
					<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span>baseFolder, <span style="color: #0000ff;">&quot;lib/h2-2.2.224.jar&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>,
			<span style="color: #000066; font-weight: bold;">null</span>,
			<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span>baseFolder, <span style="color: #0000ff;">&quot;datamodel/Demo-Scott&quot;</span><span style="color: #009900;">&#41;</span>,
			<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span>baseFolder, <span style="color: #0000ff;">&quot;extractionmodel/Demo-Scott.jm&quot;</span><span style="color: #009900;">&#41;</span>,
			ScriptFormat.<span style="color: #006633;">SQL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// The importer</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> Importer importer <span style="color: #339933;">=</span>
		<span style="color: #000000; font-weight: bold;">new</span> Importer<span style="color: #009900;">&#40;</span>
			<span style="color: #000000; font-weight: bold;">new</span> BasicDataSource<span style="color: #009900;">&#40;</span>
				<span style="color: #0000ff;">&quot;org.h2.Driver&quot;</span>, <span style="color: #0000ff;">&quot;jdbc:h2:&quot;</span> <span style="color: #339933;">+</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span>baseFolder, <span style="color: #0000ff;">&quot;demo-db/demo-scott-subset&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getAbsolutePath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #0000ff;">&quot;sa&quot;</span>, <span style="color: #0000ff;">&quot;&quot;</span>,
				POOL_SIZE,
				<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span>baseFolder, <span style="color: #0000ff;">&quot;lib/h2-2.2.224.jar&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * Exports data related with employee &quot;SCOTT&quot;
	 * and imports it into another database.
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">SQLException</span>, <span style="color: #003399;">IOException</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">File</span> exportScriptFile <span style="color: #339933;">=</span> Configuration.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">createTempFile</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		subsetter.<span style="color: #006633;">setUpsertOnly</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// overwrite previous data</span>
		subsetter.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;NAME='SCOTT'&quot;</span>, exportScriptFile<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		importer.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span>exportScriptFile<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		exportScriptFile.<span style="color: #006633;">delete</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;</pre>
                                </li>
                              </ul>
                            </td>
                          </tr>
                        </tbody>
                      </table>
                    </div>

                    <p><br /></p>

                    <p><br /></p>

                    <p><br />
                    &nbsp;</p>
                  </td>
                </tr>

                <tr>
                  <td height="12" valign="top" width="14%"><br /></td>

                  <td><br /></td>
                </tr>
              </tbody>
            </table>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</body>
</html>
